<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>会员管理</title>
	<link rel="stylesheet" href="__ACSS__/table.css">
	<link rel="stylesheet" href="__ACSS__/message.css">
	<link rel="stylesheet" href="__ACSS__/zeroModal.css">
	<script src="__AJS__/jquery-3.3.1.min.js"></script>
	<script src="__AJS__/common.js"></script>
    <script src="__AJS__/message.min.js"></script>
    <script src="__AJS__/zeroModal.min.js"></script>
</head>
<body>
	<div class="table-wrap">
		<div class="table-main">
			<div class="ibox-title">
				<h3>会员列表<small>{$list->total()}人</small></h3>
			</div>
			<div class="ibox-content">	
				<form action="{:url('admin/user/index')}" class="form-main" method="post">
					<input type="hidden" name="c" value="user">
					<div class="form-btn">
						<a href="{:url('admin/user/create')}" target="myIframe">+ 新增用户</a>
					</div>
					<div class="form-search">
						<input type="text"  class="form-control"  name="search"  placeholder="以手机号查找" >
						<input type="submit" class="search-btn" value="搜索">
					</div>
				</form>
				<table class="list-table">
					<thead>
						<tr>
                            <th>用户ID</th>
                            <th>头像</th>
                           	<th>用户名</th>	
                            <th>电话</th>
                            <th>邮箱</th>
                            <th>级别</th>
                            <th>状态</th>
                            <th>创建时间</th>
                            <th>操作</th>
                       </tr>
					</thead>
					<tbody>
						
						{volist name="list" key="k" id="v"}
							<tr>
								<td>{$v.uid}</td>
								<td><img src="" alt=""></td>
								<td>{$v.username}</td>
								<td>{$v.tel}</td>
								<td>{$v.email}</td>
								<td>
									{switch $v.level}
									{case 1}免费版{/case}
									{case 2}标准版{/case}
									{case 3}旗舰版{/case}
									{default /}无版本
									{/switch}
								</td>
								<td>
									{switch $v.status}
									{case 1}已启用{/case}
									{case 2}已禁用{/case}
									{default /}无状态
									{/switch}
								</td>
								<td>{:date('Y-m-d H:i', $v.createTime)}</td>
								<td>
									<div class="btn-group">
										<a href="{:url('admin/user/edit', ['uid' => $v.uid ])}" class="btn-white">编辑</a>
										<a href="javaScript:void(0)" data-id="{$v.uid}" class="btn-white delete-btn">删除</a>
										<a href="{:url('admin/user/info', ['uid' => $v.uid ])}" class="btn-white">详情</a>
										<a href="{:url('admin/user/updatePass', ['uid' => $v.uid ])}" class="btn-white">密码修改</a>
									</div>
								</td>
							</tr>
						{/volist}

					</tbody>
				</table>

				<div class="btn-limit-group">
					<div class="btn">
						{$page}
					</div>
				</div>
			</div>
		</div>
	</div>

	<script>

        $(function () {
            // 触发提交删除用户
            $('.delete-btn').click(function () {

                var uid = $(this).attr('data-id');
                var obj = $(this).parents('tr');

                zeroModal.confirm({
                    content: '您确定删除吗？',
                        contentDetail: '删除后将无法恢复!',
                        okFn: function() {
                        // 执行添加操作
                        delAjax(uid, obj);
                    }
                });

            });
        });

        // 执行AJAX删除数据
        function delAjax(uid, obj) {
            $.ajax({
                type: 'delete',
                url: '/admin/user/delete/uid/' + uid,
                dataType: 'json',
                success: function (data) {
                    if (data.status) {
                        zeroModal.success(data.info);
                        obj.remove();
                    } else {
                        zeroModal.error(data.info);
                    }
                },
                error: function (data) {
                    alert('AJAX执行失败!');
                }
            });
        }
	</script>
</body>
</html>